//package com.espoir.shp.demo;
//
//import org.geotools.data.FeatureSource;
//import org.geotools.data.shapefile.ShapefileDataStore;
//import org.geotools.data.simple.SimpleFeatureCollection;
//import org.geotools.data.simple.SimpleFeatureSource;
//import org.geotools.geojson.GeoJSONUtil;
//import wcontour.Contour;
//import wcontour.Interpolate;
//import wcontour.global.Border;
//import wcontour.global.PolyLine;
//import wcontour.global.Polygon;
//
//import java.io.File;
//import java.nio.charset.Charset;
//import java.util.ArrayList;
//import java.util.List;
//
//public class Demo {
//    public static void main(String[] args) {
//        test();
//    }
//
//    private static void test() {
//
//        String geojsonpogylon = "";
//        try {
//            double _undefData = -9999.0;
//            SimpleFeatureCollection polygonCollection = null;
//            List<PolyLine> cPolylineList = new ArrayList<PolyLine>();
//            List<Polygon> cPolygonList = new ArrayList<Polygon>();
//
//            int width = size[0],
//                    height = size[1];
//            double[] _X = new double[width];
//            double[] _Y = new double[height];
//
//            File file = new File(boundryFile);
//            ShapefileDataStore shpDataStore = null;
//
//            shpDataStore = new ShapefileDataStore(file.toURL());
//            //设置编码
//            Charset charset = Charset.forName("GBK");
//            shpDataStore.setCharset(charset);
//            String typeName = shpDataStore.getTypeNames()[0];
//            SimpleFeatureSource featureSource = null;
//            featureSource = shpDataStore.getFeatureSource(typeName);
//            SimpleFeatureCollection fc = featureSource.getFeatures();
//
//            double minX = fc.getBounds().getMinX();
//            double minY = fc.getBounds().getMinY();
//            double maxX = fc.getBounds().getMaxX();
//            double maxY = fc.getBounds().getMaxY();
//
//            Interpolate.CreateGridXY_Num(minX, minY, maxX, maxY, _X, _Y);
//            double[][] _gridData = new double[width][height];
//
//            int nc = dataInterval.length;
//
//            _gridData = Interpolate.Interpolation_IDW_Neighbor(trainData,
//                    _X, _Y, 12, _undefData);// IDW插值
//
//            int[][] S1 = new int[_gridData.length][_gridData[0].length];
//            List<Border> _borders = Contour.tracingBorders(_gridData, _X, _Y,
//                    S1, _undefData);
//
//            cPolylineList = Contour.tracingContourLines(_gridData, _X, _Y, nc,
//                    dataInterval, _undefData, _borders, S1);// 生成等值线
//
//            cPolylineList = Contour.smoothLines(cPolylineList);// 平滑
//
//            cPolygonList = Contour.tracingPolygons(_gridData, cPolylineList,
//                    _borders, dataInterval);
//
//            geojsonpogylon = getPolygonGeoJson(cPolygonList);
//
//            if (isclip) {
//                polygonCollection = GeoJSONUtil.readGeoJsonByString(geojsonpogylon);
//                FeatureSource dc = clipFeatureCollection(fc, polygonCollection);
//                geojsonpogylon = getPolygonGeoJson(dc.getFeatures());
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//    }
//}
